package com.ruoyi.business.service.impl;

import com.ruoyi.business.mapper.WsdDishesMapper;
import com.ruoyi.business.service.IWsdDishesService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.WsdDishes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;

/**
 * 菜品信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-04-22
 */
@Service
public class WsdDishesServiceImpl implements IWsdDishesService
{
    @Autowired
    private WsdDishesMapper wsdDishesMapper;

    /**
     * 查询菜品信息
     * 
     * @param dishId 菜品信息主键
     * @return 菜品信息
     */
    @Override
    public WsdDishes selectWsdDishesByDishId(Long dishId)
    {
        return wsdDishesMapper.selectWsdDishesByDishId(dishId);
    }

    /**
     * 查询菜品信息列表
     * 
     * @param wsdDishes 菜品信息
     * @return 菜品信息
     */
    @Override
    public List<WsdDishes> selectWsdDishesList(WsdDishes wsdDishes)
    {
        SysUser user = getLoginUser().getUser();
        wsdDishes.setSchoolId(user.getSchoolId());
        return wsdDishesMapper.selectWsdDishesList(wsdDishes);
    }

    /**
     * 新增菜品信息
     * 
     * @param wsdDishes 菜品信息
     * @return 结果
     */
    @Override
    public int insertWsdDishes(WsdDishes wsdDishes)
    {
        SysUser user = getLoginUser().getUser();
        wsdDishes.setSchoolId(user.getSchoolId());
        return wsdDishesMapper.insertWsdDishes(wsdDishes);
    }

    /**
     * 修改菜品信息
     * 
     * @param wsdDishes 菜品信息
     * @return 结果
     */
    @Override
    public int updateWsdDishes(WsdDishes wsdDishes)
    {
        SysUser user = getLoginUser().getUser();
        wsdDishes.setSchoolId(user.getSchoolId());
        return wsdDishesMapper.updateWsdDishes(wsdDishes);
    }

    /**
     * 批量删除菜品信息
     * 
     * @param dishIds 需要删除的菜品信息主键
     * @return 结果
     */
    @Override
    public int deleteWsdDishesByDishIds(Long[] dishIds)
    {
        return wsdDishesMapper.deleteWsdDishesByDishIds(dishIds);
    }

    /**
     * 删除菜品信息信息
     * 
     * @param dishId 菜品信息主键
     * @return 结果
     */
    @Override
    public int deleteWsdDishesByDishId(Long dishId)
    {
        return wsdDishesMapper.deleteWsdDishesByDishId(dishId);
    }
}
